#Makefile for cbar-five

CC	= gcc
BIN	= cbar-five
LDFLAGS	= `sdl-config --libs` -Llibbase -lbase -Lgui -lgui \
	  -lSDL_ttf -lSDL_image -lSDL_mixer -lSDL_gfx -g
CFLAGS	= `sdl-config --cflags` -Ilibbase -Igui -g -Wall
SOURCES = main.c fivekernel.c ai.c if_mainmenu.c if_playpanel.c singleplay.c
OBJS	= $(SOURCES:.c=.o)
DEPENDS = $(OBJS:.o=.d)

.PHONY: libbase libgui clean cleanbak

$(BIN):$(DEPENDS) $(OBJS) libbase libgui 
	$(CC) -o $(BIN) $(OBJS) $(LDFLAGS)

-include $(DEPENDS)
$(DEPENDS):
	@echo -n $@ " " > $@
	@$(CC) -MM $(@:.d=.c) >> $@ $(CFLAGS)

libbase:
	(cd libbase; make)

libgui:
	(cd gui; make)

clean:
	rm -f $(BIN) $(OBJS) $(DEPENDS)
	(cd libbase; make clean)
	(cd gui; make clean)
cleanbak:
	rm -f *~
	(cd libbase; make cleanbak)
	(cd gui; make cleanbak)
